package net.atos.excercise1;

import java.util.Collection;

import org.springframework.stereotype.Component;

import com.google.common.collect.Sets;

@Component
public class LibraryImpl implements Library {

    public Collection<Book> findByName(final String name) {
	final Collection<Book> foundBooks = Sets.newHashSet();
	for (final Book book : BOOKS) {
	    if (book.getName().startsWith(name)) {
		foundBooks.add(book);
	    }
	}
	return foundBooks;
    }

    private static Collection<Book> BOOKS = Sets.newHashSet(
	    new Book("JRRT Tolkien", "Lord of the Rings"),
	    new Book("Joseph Condrad", "Lord Jim"),
	    new Book("William Golding", "Lord of the flies"),
	    new Book("Unknown", "Uncle Jim")
	    );
}
